package com.shioirikukuri.controller;

import com.shioirikukuri.entity.SpecialPrice;
import com.shioirikukuri.service.ISpecialPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/special-prices")
public class SpecialPriceController {

	@Autowired
	private ISpecialPriceService specialPriceService;

	/*
	 * 获取所有特殊价格信息
	 */
	@GetMapping
	public List<SpecialPrice> getAllSpecialPrices() {
		return specialPriceService.getAllSpecialPrices();
	}

	/*
	 * 根据ID获取特殊价格信息
	 */
	@GetMapping("/{priceId}")
	public SpecialPrice getSpecialPriceById(@PathVariable Integer priceId) {
		return specialPriceService.getSpecialPriceById(priceId);
	}

	/*
	 * 创建特殊价格信息
	 */
	@PostMapping
	public void createSpecialPrice(@RequestBody SpecialPrice specialPrice) {
		specialPriceService.createSpecialPrice(specialPrice);
	}

	/*
	 * 更新特殊价格信息
	 */
	@PutMapping("/{priceId}")
	public void updateSpecialPrice(@PathVariable Integer priceId, @RequestBody SpecialPrice specialPrice) {
		specialPriceService.updateSpecialPrice(specialPrice);
	}

	/*
	 * 根据ID删除特殊价格信息
	 */
	@DeleteMapping("/{priceId}")
	public void deleteSpecialPriceById(@PathVariable Integer priceId) {
		specialPriceService.deleteSpecialPriceById(priceId);
	}
}